

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.Timer;


public class GamePanel extends JPanel implements ActionListener {
	
	Timer t;
	GameState game;
	JPopupMenu menu;
	public GamePanel(JFrame parent){
		this.setBackground(Color.BLACK);
		t = new Timer(10, this);
		this.setSize(parent.getSize());
		game = new RTSGameState(t);
		this.addMouseListener(game);
		this.addMouseMotionListener(game);
		this.addMouseWheelListener(game);
		menu = new JPopupMenu();
		t.start();
	}

	@Override
	public void paint(Graphics g){
		Graphics2D g2d = (Graphics2D)g;
		super.paint(g);
		
		game.draw(g2d);
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		this.repaint();
	}

	public static void main(String[] args){
		JFrame frame = new JFrame("Particles");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(1024, 720);
		GamePanel pp = new GamePanel(frame);
		//frame.addMouseListener(pp);
		//frame.addMouseMotionListener(pp);
		//frame.addMouseWheelListener(pp);
		frame.add(pp);
		frame.setVisible(true);

	}
}
